home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: cs.dal.ca!ug!mzhang
- From: mzhang@ug.cs.dal.ca (MAONI ZHANG)
- Subject: Mastermind
- Message-ID: <Dn4Eyq.Kpw@cs.dal.ca>
- Sender: usenet@cs.dal.ca (USENET News)
- Nntp-Posting-Host: ug.cs.dal.ca
- Organization: Math, Stats & CS, Dalhousie University, Halifax, NS, Canada
- X-Newsreader: TIN [version 1.2 PL2]
- Date: Wed, 21 Feb 1996 10:11:13 GMT
-
- Hello All,
-
- I can't figure out a good way to programm mastermind, here's the description
- of it:
-
- /* beginning of the description */
-
-
- Mastermind is a popular children's game. One player is the "codemaker"
- M who chooses a code represented by four coloured pegs. The other
- player is the "code-breaker" B who is allowed up to 10 guesses at the
- code. B wins if (s)he guesses the code within 10 trys otherwise M wins.
- It may also be interesting to keep track of statistics on the number of
- guesses required.
-
- After each guess M reports a score which contains partial information.
- The score has two parts, viz, the number of exact matches and the
- number of matches in the wrong position. It helps to consider an
- example. Suppose the secret code is (Red White Black Black) and B
- guesses (Black Black Red Black). The score in this case would be one
- exact match (the fourth position) and two "other" matches (the first
- Black and the third Red in the guess). Note that no coloured peg in the
- code can match more than one position in the guess and so the second
- Black in the guess has nothing left to match with after the other
- matches have been paired off. Scoring is surprisingly difficult for
- human players and both players must be adept at it.
-
- The question of what strategy he codebreaker B should use to pick
- guesses is very interesting. One strategy for B is to consider
- all possible guesses and to reject those that are inconsistent
- with previous guesses. An consistent guess is one which when
- scored against all previous gives the same scores. For example,
- after receiving a score of (1 2) for (Black Black Red Black) the guess
- (Black Red Black Red) is consistent (scored against (Black Black
- Red Black) it would get a score of (1 2)). Most other possible
- guesses would be inconsistent and rejected by player B.
-
- /* end of the description */
-
- The first guess would be repeating the 1st color of the 6 colors(suppose
- we need to guess 4 outta 6) for 4 times.
-
-
- I couldn't think of a good algorithm to do it. it need to be done in c/c++.
-
-
- Please email me at mzhang@ug.cs.dal.ca if you get any idea. Thanks for any
- suggestions.
-
-
- -Maoni
-